var express = require("express");
var router = express.Router();

router.post("/", function(req,res){
  const {name, email} = req.body;
  // const name = req.body.name;
  // const email = req.body.email;
  let errors = "";
  if(!(name && name.length>2 && name.length<10)){
    errors = errors || {};
    errors.name = "name length must >2 and <10";
  }
  if(!(/^[A-Za-z]\w+@\w+\.\w+(\.\w+)?$/.test(email))){
    errors = errors || {};
    errors.email = "email's format error!!"
  }
  console.log(errors);
  res.send(errors);
});


module.exports = router;
